home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / LhALZXDirDOps5 / LhaDirStoneD-handler < prev    next >
Text File  |  1995-11-18  |  3KB  |  105 lines

  1. /*
  2.   $VER: LhaDirStoneD-handler 1.0 (18.11.95)
  3.  
  4.   modified by Stone-D (Laga Hale)
  5.  
  6.   Mail me at stone-d@eldar.demon.co.uk
  7.  
  8.   Custom handler for LhADir.StoneD.
  9. */
  10.  
  11. options results
  12. options failat 11
  13.  
  14. parse arg portname
  15. parse var portname '.' portno
  16. address value portname
  17.  
  18. if ~show('l','rexxsupport.library') then
  19.    call addlib('rexxsupport.library',0,-30,0)
  20.  
  21. call openport('LhaDirStoneD-handler'portno)
  22.  
  23. dopus addtrap copy 'LhaDirStoneD-handler'portno
  24. dopus addtrap move 'LhaDirStoneD-handler'portno
  25. dopus addtrap delete 'LhaDirStoneD-handler'portno
  26. dopus addtrap parent 'LhaDirStoneD-handler'portno
  27. dopus addtrap makedir 'LhaDirStoneD-handler'portno
  28.  
  29. do forever
  30.    if waitpkt('LhaDirStoneD-handler'portno) then do
  31.       packet=getpkt('LhaDirStoneD-handler'portno)
  32.  
  33.       event=getarg(packet,0)
  34.       handle=getarg(packet,1)
  35.       name=getarg(packet,2)
  36.       user=getarg(packet,3)
  37.  
  38.       if upper(event)='MAKEDIR' then do
  39.             cmd='MAKEDIR'
  40.             address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD' cmd portname handle '"'name'"'
  41.       end
  42.  
  43.       if upper(event)='COPY' then do
  44.             cmd='COPY'
  45.             address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD' cmd portname handle '"'name'"'
  46.       end
  47.  
  48.       if upper(event)='MOVE' then do
  49.             cmd='MOVE'
  50.             address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD' cmd portname handle '"'name'"'
  51.       end
  52.  
  53.       if upper(event)='DELETE' then do
  54.             cmd='DELETE'
  55.             address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD' cmd portname handle '"'name'"'
  56.       end
  57.  
  58.       if upper(event)='PARENT' then do
  59.          lister query handle path
  60.          winpath=result
  61.          oldpath=getarg(packet,4)
  62.          test=upper(winpath)
  63.          newpos=lastpos('/',winpath,lastpos('/',winpath)-1)
  64.          newpos1=lastpos(':',winpath,lastpos('/',winpath)-1)
  65.          if newpos1>newpos then newpos=newpos1
  66.          newpath=left(winpath,newpos)
  67.          lister read handle '"'newpath'"' force
  68.          address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD GETDIR' portname ' ' handle '""'
  69.       end
  70.  
  71.       if upper(event)='DOUBLECLICK' then do
  72.          lister query handle entry '"'name'"' stem fileinfo.
  73.          if fileinfo.type>0 then do  /* it's a dir */
  74.             name=name'/'
  75.             cmd='GETDIR'
  76.             end
  77.          else
  78.             if pos(upper(right(name,4)),'.Lha')>0 then  /* archive in an archive */
  79.                cmd='GETDIR'
  80.             else
  81.                cmd='DOUBLECLICK'
  82.          address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD' cmd portname handle '"'name'"'
  83.          end
  84.  
  85.       if upper(event)='INACTIVE' then do
  86.          lister query handle path
  87.          winpath=result
  88.          oldpath=getarg(packet,4)
  89.          test=upper(winpath)
  90.          if winpath=left(oldpath,length(winpath))&(pos('.Lha/',test)>0) then  /* user did parent */
  91.             address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir.StoneD GETDIR' portname handle '""'
  92.          else
  93.             address command 'Delete >NIL: T:LhaDir.list'handle 'QUIET'  /* remove temp file */
  94.          end
  95.  
  96.       if upper(event)='DROP' then do
  97.          name=strip(name,'t')
  98.          if right(name,1)=':' then
  99.             lister read handle '"'name'"' force  /* user dropped a volume icon */
  100.          end
  101.  
  102.       call reply(packet,0)
  103.       end
  104.    end
  105.